/*
 * UIMatrix.fx
 *
 * Created on Oct 6, 2009, 8:57:34 PM
 */

package dawnland02.ui;

import java.util.Map;
import java.util.HashMap;

import javafx.scene.*;

import dawnland02.data.map.model.Matrix;
import dawnland02.layout.GridLayout;
import dawnland02.ui.UIHexagon;

/**
 * @author user
 */

public class UIMatrix extends CustomNode{
    package var matrix : Matrix;
    package var uiService : UIService;

    var uiHexagonsMap: Map;

    var gridLayout : GridLayout = GridLayout{
        uiService: uiService;
        content: [];
    }

    init {
        var uiHexagons = uiService.createUIHexagonsFromMatrix(matrix);
        uiHexagonsMap = new HashMap();
        for(uiHexagon in uiHexagons){
            uiHexagonsMap.put(uiHexagon.getId(), uiHexagon);
        }
        gridLayout.content = uiHexagons;
    }

    public override function create(): Node {
        return gridLayout;
    }

    public function getUIHexagon(id:Integer) : UIHexagon{
        return uiHexagonsMap.get(id) as UIHexagon;
    }
}
